<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

class Test extends Controller {

    public function testMenuGet() {
        $this->loadModel('WechatSdk');

        $st = WechatSdk::getServiceAccessToken();
        $menu = WechatSdk::getMenu($st, true);
        $menu = json_decode($menu, true);
        $menu = $menu['menu'];

        file_put_contents(dirname(__FILE__) . '/../config/wechat_menu.json', $this->unIescape(json_encode($menu)));
    }

    public function testMenuSet() {
        $this->loadModel('WechatSdk');

        $menu = file_get_contents(dirname(__FILE__) . '/../config/wechat_menu.json');
        var_dump($menu);
        $st = WechatSdk::getServiceAccessToken();
        $rst = WechatSdk::setMenu($st, $menu);

        var_dump($rst);
    }

}
